﻿namespace 找出最长的递增子序列
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int length = MyClass.LengthOfLIS(new int[] { 1, 3, 2, 4, 5, 6 });
            Console.WriteLine(length);
            Console.ReadKey();
        }
    }
    /// <summary>
    /// 暴力搜素
    /// </summary>
    class MyClass
    {
        /// <summary>
        /// 暴力搜索  1   5   3  2  4         1   2   4      1   3   4
        /// </summary>
        /// <param name="nums"></param>
        /// <returns></returns>
        public static int LengthOfLIS(int[] nums)
        {
            int maxLength = 1;
            int i = 0;
            int j = 1;
            List<int> list = new List<int>();
            while (i < nums.Length - 1)
            {
               
                maxLength = 1;
                j = i + 1;
                if (nums[i] < nums[j])
                {
                    maxLength++;
                    j++;
                    if (j == nums.Length - 1)
                    {
                        break;
                    }
                    while (nums[j] < nums[j + 1])
                    {
                        maxLength++;
                        j++;
                        if (j == nums.Length - 1)
                        {
                            if (nums[j] > nums[j - 1])
                            {
                                maxLength++;
                            }
                            break;
                        }
                    }
                }
                i++;
                list.Add(maxLength);
            }
            return list.Max();
           
        }
    }
}